Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Add new templates for legacy buyer notices in WooCommerce core #8732

Merged
merged 7 commits into from
Mar 28, 2023

Conversation

mikejolley
Copy link
Member

This is a solution to apply the new notice designs to legacy notices in WooCommerce core from the Blocks side. I'm basing this on the #8659 branch.

It works by using the wc_get_template filter to replace the core template with the modified block template. The modified template includes new markup and an SVG icon (something we cannot do with CSS alone).

For styles, we just enqueue the blocks CSS stylesheet. It should be cached most of the time if the store is using blocks.

Screenshots

These are examples of core notices with the new template + styling applied:

Screenshot 2023-03-14 at 14 34 16
Screenshot 2023-03-14 at 14 34 22
Screenshot 2023-03-14 at 14 34 27
Screenshot 2023-03-14 at 14 34 34

Testing

Automated Tests

  • Changes in this PR are covered by Automated Tests.
    • Unit tests
    • E2E tests

User Facing Testing

  1. Add something to the cart to see the success notice.
  2. Limit the inventory of an item to 1, then add 2 to your cart. This will reveal the error notice.
  3. You can test other notice types using the wc_add_notice function.
  • Do not include in the Testing Notes

WooCommerce Visibility

  • WooCommerce Core
  • Feature plugin
  • Experimental

@mikejolley mikejolley added the block: checkout Issues related to the checkout block. label Mar 14, 2023
@mikejolley mikejolley self-assigned this Mar 14, 2023
@woocommercebot woocommercebot requested review from a team and wavvves and removed request for a team March 14, 2023 14:38
@github-actions
Copy link
Contributor

github-actions bot commented Mar 14, 2023

The release ZIP for this PR is accessible via:

https://wcblocks.wpcomstaging.com/wp-content/uploads/woocommerce-gutenberg-products-block-8732.zip

Script Dependencies Report

There is no changed script dependency between this branch and trunk.

This comment was automatically generated by the ./github/compare-assets action.

TypeScript Errors Report

  • Files with errors: 479
  • Total errors: 2300

⚠️ ⚠️ This PR introduces new TS errors on 72 files:

assets/js/atomic/blocks/product-elements/shared/product-selector.tsx

assets/js/atomic/blocks/product-elements/shared/with-product-selector.js

assets/js/atomic/blocks/product-elements/title/block.tsx

assets/js/base/components/cart-checkout/address-form/address-form.tsx

assets/js/base/components/cart-checkout/address-form/test/index.js

assets/js/base/components/cart-checkout/product-badge/index.tsx

assets/js/base/components/cart-checkout/shipping-calculator/address.tsx

assets/js/base/components/cart-checkout/totals/coupon/index.tsx

assets/js/base/components/country-input/country-input.tsx

assets/js/base/components/product-list/product-list.tsx

assets/js/base/components/product-list/product-sort-select/index.tsx

assets/js/base/components/product-name/index.tsx

assets/js/base/components/radio-control/option-layout.tsx

assets/js/base/components/read-more/index.tsx

assets/js/base/components/reviews/review-sort-select/index.tsx

assets/js/base/components/state-input/state-input.tsx

assets/js/base/components/title/index.tsx

assets/js/blocks/active-filters/edit.tsx

assets/js/blocks/attribute-filter/edit.tsx

assets/js/blocks/cart-checkout-shared/payment-methods/payment-method-options.js

assets/js/blocks/cart-checkout-shared/sidebar-notices/index.tsx

assets/js/blocks/cart/inner-blocks/cart-order-summary-coupon-form/block.tsx

assets/js/blocks/checkout/inner-blocks/checkout-billing-address-block/block.tsx

assets/js/blocks/checkout/inner-blocks/checkout-contact-information-block/block.tsx

assets/js/blocks/checkout/inner-blocks/checkout-order-summary-coupon-form/block.tsx

assets/js/blocks/checkout/inner-blocks/checkout-pickup-options-block/block.tsx

assets/js/blocks/checkout/inner-blocks/checkout-shipping-address-block/block.tsx

assets/js/blocks/checkout/inner-blocks/checkout-terms-block/test/frontend.js

assets/js/blocks/checkout/phone-number/index.tsx

assets/js/blocks/featured-items/block-controls.tsx

assets/js/blocks/featured-items/image-editor.tsx

assets/js/blocks/featured-items/inspector-controls.tsx

assets/js/blocks/featured-items/with-api-error.tsx

assets/js/blocks/featured-items/with-edit-mode.tsx

assets/js/blocks/featured-items/with-editing-image.tsx

assets/js/blocks/featured-items/with-featured-item.tsx

assets/js/blocks/featured-items/with-update-button-attributes.tsx

assets/js/blocks/price-filter/edit.tsx

assets/js/blocks/product-best-sellers/inspector-controls.tsx

assets/js/blocks/product-category/edit-mode.tsx

assets/js/blocks/product-category/inspector-controls.tsx

assets/js/blocks/product-new/block.js

assets/js/blocks/product-on-sale/block.js

assets/js/blocks/product-query/inspector-controls.tsx

assets/js/blocks/product-query/inspector-controls/attributes-filter.tsx

assets/js/blocks/product-top-rated/block.js

assets/js/blocks/products-by-attribute/edit-mode.tsx

assets/js/blocks/products-by-attribute/inspector-controls.tsx

assets/js/blocks/reviews/reviews-by-category/edit.js

assets/js/blocks/reviews/reviews-by-product/edit.js

assets/js/blocks/stock-filter/edit.tsx

assets/js/editor-components/search-list-control/item.tsx

assets/js/extensions/shipping-methods/pickup-location/general-settings.tsx

assets/js/extensions/shipping-methods/shared-components/settings-card/index.tsx

assets/js/extensions/shipping-methods/shared-components/settings-modal/index.tsx

assets/js/hocs/test/with-categories.js

assets/js/hocs/test/with-category.js

assets/js/hocs/test/with-product-variations.js

assets/js/hocs/test/with-product.js

assets/js/hocs/test/with-transform-single-select-to-multiple-select.js

assets/js/hocs/with-product-variations.js

assets/js/hocs/with-transform-single-select-to-multiple-select.js

assets/js/types/type-defs/blocks.ts

node_modules/@types/react/index.d.ts

node_modules/@types/wordpress__components/node_modules/@types/react/index.d.ts

node_modules/framer-motion/dist/framer-motion.d.ts

packages/checkout/components/panel/index.tsx

packages/checkout/components/store-notices-container/index.tsx

packages/checkout/components/store-notices-container/snackbar-notices.tsx

packages/checkout/components/text-input/text-input.tsx

packages/checkout/components/totals-wrapper/index.tsx

packages/checkout/components/totals/item/index.tsx

comments-aggregator

@github-actions
Copy link
Contributor

github-actions bot commented Mar 14, 2023

Size Change: +82 B (0%)

Total Size: 1.09 MB

Filename Size Change
build/wc-blocks-style-rtl.css 27.2 kB +41 B (0%)
build/wc-blocks-style.css 27.2 kB +41 B (0%)
ℹ️ View Unchanged
Filename Size
build/active-filters-frontend.js 7.99 kB
build/active-filters-wrapper-frontend.js 6.01 kB
build/active-filters.js 7.49 kB
build/all-products-frontend.js 11.8 kB
build/all-products.js 36.8 kB
build/all-reviews.js 7.66 kB
build/attribute-filter-frontend.js 22.5 kB
build/attribute-filter-wrapper--stock-filter-wrapper-frontend.js 3.38 kB
build/attribute-filter-wrapper-frontend.js 4.5 kB
build/attribute-filter.js 13.2 kB
build/blocks-checkout.js 66 kB
build/breadcrumbs.js 2.05 kB
build/cart-blocks/cart-accepted-payment-methods-frontend.js 1.38 kB
build/cart-blocks/cart-cross-sells-frontend.js 253 B
build/cart-blocks/cart-cross-sells-products-frontend.js 9.76 kB
build/cart-blocks/cart-express-payment--checkout-blocks/express-payment-frontend.js 5.2 kB
build/cart-blocks/cart-express-payment-frontend.js 719 B
build/cart-blocks/cart-items-frontend.js 301 B
build/cart-blocks/cart-line-items--mini-cart-contents-block/products-table-frontend.js 5.36 kB
build/cart-blocks/cart-line-items-frontend.js 1.07 kB
build/cart-blocks/cart-order-summary-frontend.js 1.24 kB
build/cart-blocks/cart-totals-frontend.js 307 B
build/cart-blocks/empty-cart-frontend.js 346 B
build/cart-blocks/filled-cart-frontend.js 656 B
build/cart-blocks/order-summary-coupon-form-frontend.js 1.62 kB
build/cart-blocks/order-summary-discount-frontend.js 2.12 kB
build/cart-blocks/order-summary-fee-frontend.js 274 B
build/cart-blocks/order-summary-heading-frontend.js 455 B
build/cart-blocks/order-summary-shipping-frontend.js 11.5 kB
build/cart-blocks/order-summary-subtotal-frontend.js 275 B
build/cart-blocks/order-summary-taxes-frontend.js 434 B
build/cart-blocks/proceed-to-checkout-frontend.js 1.33 kB
build/cart-frontend.js 29.3 kB
build/cart.js 48.6 kB
build/catalog-sorting.js 1.7 kB
build/checkout-blocks/actions-frontend.js 1.85 kB
build/checkout-blocks/billing-address-frontend.js 4.18 kB
build/checkout-blocks/contact-information-frontend.js 2.05 kB
build/checkout-blocks/express-payment-frontend.js 1.13 kB
build/checkout-blocks/fields-frontend.js 331 B
build/checkout-blocks/order-note-frontend.js 1.14 kB
build/checkout-blocks/order-summary-cart-items-frontend.js 3.68 kB
build/checkout-blocks/order-summary-coupon-form-frontend.js 1.78 kB
build/checkout-blocks/order-summary-discount-frontend.js 2.29 kB
build/checkout-blocks/order-summary-fee-frontend.js 277 B
build/checkout-blocks/order-summary-frontend.js 1.24 kB
build/checkout-blocks/order-summary-shipping-frontend.js 11.6 kB
build/checkout-blocks/order-summary-subtotal-frontend.js 275 B
build/checkout-blocks/order-summary-taxes-frontend.js 434 B
build/checkout-blocks/payment-frontend.js 8.78 kB
build/checkout-blocks/pickup-options-frontend.js 4.04 kB
build/checkout-blocks/shipping-address-frontend.js 4.14 kB
build/checkout-blocks/shipping-method-frontend.js 2.61 kB
build/checkout-blocks/shipping-methods-frontend.js 5.81 kB
build/checkout-blocks/terms-frontend.js 1.56 kB
build/checkout-blocks/totals-frontend.js 310 B
build/checkout-frontend.js 30.9 kB
build/checkout.js 46.1 kB
build/customer-account.js 3.16 kB
build/featured-category.js 14 kB
build/featured-product.js 14.4 kB
build/filter-wrapper-frontend.js 14.1 kB
build/filter-wrapper.js 2.39 kB
build/general-style-rtl.css 1.31 kB
build/general-style.css 1.31 kB
build/handpicked-products.js 7.9 kB
build/legacy-template.js 5.32 kB
build/mini-cart-component-frontend.js 28 kB
build/mini-cart-contents-block/empty-cart-frontend.js 359 B
build/mini-cart-contents-block/filled-cart-frontend.js 268 B
build/mini-cart-contents-block/footer-frontend.js 2.85 kB
build/mini-cart-contents-block/items-frontend.js 237 B
build/mini-cart-contents-block/products-table-frontend.js 589 B
build/mini-cart-contents-block/shopping-button-frontend.js 573 B
build/mini-cart-contents-block/title-frontend.js 368 B
build/mini-cart-contents.js 17 kB
build/mini-cart-frontend.js 2.02 kB
build/mini-cart.js 4.49 kB
build/price-filter-frontend.js 13.9 kB
build/price-filter-wrapper-frontend.js 7.01 kB
build/price-filter.js 8.4 kB
build/price-format.js 1.19 kB
build/product-add-to-cart-frontend.js 6.43 kB
build/product-add-to-cart.js 178 B
build/product-best-sellers.js 8.25 kB
build/product-button-frontend.js 1.98 kB
build/product-categories.js 2.36 kB
build/product-category.js 9.23 kB
build/product-image-frontend.js 1.83 kB
build/product-image.js 177 B
build/product-new.js 8.25 kB
build/product-on-sale.js 8.58 kB
build/product-price-frontend.js 2.14 kB
build/product-query.js 11 kB
build/product-rating-frontend.js 1.4 kB
build/product-results-count.js 1.65 kB
build/product-sale-badge-frontend.js 1.04 kB
build/product-search.js 2.63 kB
build/product-sku-frontend.js 453 B
build/product-stock-indicator-frontend.js 1.07 kB
build/product-summary-frontend.js 1.35 kB
build/product-tag.js 8.73 kB
build/product-title-frontend.js 1.41 kB
build/product-title.js 178 B
build/product-top-rated.js 8.49 kB
build/products-by-attribute.js 9.56 kB
build/rating-filter-frontend.js 20.9 kB
build/rating-filter-wrapper-frontend.js 5.63 kB
build/rating-filter.js 7.44 kB
build/reviews-by-category.js 11.9 kB
build/reviews-by-product.js 13 kB
build/reviews-frontend.js 7.11 kB
build/stock-filter-frontend.js 21.1 kB
build/stock-filter-wrapper-frontend.js 3.16 kB
build/stock-filter.js 8.17 kB
build/store-notices.js 1.69 kB
build/vendors--attribute-filter-wrapper--cart-blocks/cart-cross-sells-products--cart-blocks/order-summary--82e4ed06-frontend.js 6.84 kB
build/vendors--attribute-filter-wrapper--rating-filter-wrapper--stock-filter-wrapper-frontend.js 7.69 kB
build/vendors--cart-blocks/cart-cross-sells-products--cart-blocks/cart-line-items--cart-blocks/cart-order--3c5fe802-frontend.js 5.26 kB
build/vendors--cart-blocks/cart-cross-sells-products--cart-blocks/order-summary-shipping--checkout-blocks--18f9376a-frontend.js 19.4 kB
build/vendors--cart-blocks/cart-cross-sells-products--product-add-to-cart-frontend.js 7.25 kB
build/vendors--cart-blocks/cart-line-items--checkout-blocks/order-summary-cart-items--mini-cart-contents---233ab542-frontend.js 3.14 kB
build/vendors--cart-blocks/order-summary-shipping--checkout-blocks/order-summary-shipping--checkout-block--24d3fc0c-frontend.js 8.25 kB
build/vendors--checkout-blocks/billing-address--checkout-blocks/shipping-address-frontend.js 5.44 kB
build/vendors--checkout-blocks/shipping-method-frontend.js 12 kB
build/wc-blocks-data.js 21.8 kB
build/wc-blocks-editor-style-rtl.css 5.78 kB
build/wc-blocks-editor-style.css 5.78 kB
build/wc-blocks-google-analytics.js 1.56 kB
build/wc-blocks-middleware.js 933 B
build/wc-blocks-registry.js 3.15 kB
build/wc-blocks-shared-context.js 1.52 kB
build/wc-blocks-shared-hocs.js 1.73 kB
build/wc-blocks-vendors-style-rtl.css 1.96 kB
build/wc-blocks-vendors-style.css 1.96 kB
build/wc-blocks-vendors.js 63.9 kB
build/wc-blocks.js 2.63 kB
build/wc-payment-method-bacs.js 816 B
build/wc-payment-method-cheque.js 811 B
build/wc-payment-method-cod.js 909 B
build/wc-payment-method-paypal.js 837 B
build/wc-settings.js 2.6 kB
build/wc-shipping-method-pickup-location.js 29.9 kB
build/woo-directives-runtime.js 2.73 kB
build/woo-directives-vendors.js 7.91 kB

compressed-size-action

templates/notices/error.php Outdated Show resolved Hide resolved
templates/notices/error.php Outdated Show resolved Hide resolved
src/Domain/Services/Notices.php Outdated Show resolved Hide resolved
@mikejolley mikejolley requested a review from wavvves March 21, 2023 12:09
Copy link
Contributor

@wavvves wavvves left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@github-actions github-actions bot added this to the 9.9.0 milestone Mar 21, 2023
@mikejolley mikejolley force-pushed the refactor/buyer-notices branch from e33a757 to 1bdba0f Compare March 23, 2023 11:26
@tarunvijwani tarunvijwani modified the milestones: 9.9.0, 10.0.0 Mar 27, 2023
@mikejolley mikejolley force-pushed the add/legacy-buyer-notices branch from 2d396fe to e84bf3c Compare March 28, 2023 08:55
@mikejolley mikejolley merged commit 91a9b99 into refactor/buyer-notices Mar 28, 2023
@mikejolley mikejolley deleted the add/legacy-buyer-notices branch March 28, 2023 09:49
mikejolley added a commit that referenced this pull request Mar 31, 2023
* Add templates for legacy core notices

* Update src/Domain/Services/Notices.php

Co-authored-by: Paulo Arromba <[email protected]>

* Remove debugging code

* DRY get_notices_template

* Simplify error template

* Fix padding

* Only include new notices if using block cart/checkout

---------

Co-authored-by: Paulo Arromba <[email protected]>
mikejolley added a commit that referenced this pull request Apr 4, 2023
* Add templates for legacy core notices

* Update src/Domain/Services/Notices.php

Co-authored-by: Paulo Arromba <[email protected]>

* Remove debugging code

* DRY get_notices_template

* Simplify error template

* Fix padding

* Only include new notices if using block cart/checkout

---------

Co-authored-by: Paulo Arromba <[email protected]>
mikejolley added a commit that referenced this pull request Apr 5, 2023
* Add templates for legacy core notices

* Update src/Domain/Services/Notices.php

Co-authored-by: Paulo Arromba <[email protected]>

* Remove debugging code

* DRY get_notices_template

* Simplify error template

* Fix padding

* Only include new notices if using block cart/checkout

---------

Co-authored-by: Paulo Arromba <[email protected]>
mikejolley added a commit that referenced this pull request Apr 5, 2023
* Notice banner component

* Snackbar support

* Switch to new components

* Finish snackbar implementation

* Summary notice

* Styling issues

* Fix text wrap in shipping calculator

* Storybook entries

* Docs and tests for NoticeBanner

* Framer motion to avoid components dependency

* Snackbar list stories

* Docs for snackbar list

* Update assets/js/base/components/notice-banner/README.md

Co-authored-by: Thomas Roberts <[email protected]>

* Update assets/js/base/components/notice-banner/README.md

Co-authored-by: Thomas Roberts <[email protected]>

* Update assets/js/base/components/notice-banner/README.md

Co-authored-by: Thomas Roberts <[email protected]>

* Update assets/js/base/components/notice-banner/README.md

Co-authored-by: Thomas Roberts <[email protected]>

* Update assets/js/base/components/notice-banner/README.md

Co-authored-by: Thomas Roberts <[email protected]>

* Types/docblocks

* Docs

* Update notice type

* Use NoticeBannerProps for type of noticeProps

* Raw html to fix notice encoding

* getClassNameFromStatus is unused

* Update position text

* Clarify notice text

* Fix hover style in whisper TT3 theme

* remove div styles

* Add new templates for legacy buyer notices in WooCommerce core (#8732)

* Add templates for legacy core notices

* Update src/Domain/Services/Notices.php

Co-authored-by: Paulo Arromba <[email protected]>

* Remove debugging code

* DRY get_notices_template

* Simplify error template

* Fix padding

* Only include new notices if using block cart/checkout

---------

Co-authored-by: Paulo Arromba <[email protected]>

* Fix view box tag

* Hover and focus styles

* Styling when notices added via ajax

* Remove margin change

* Implement react-transition-group instead of framer (#8920)

* Add screenshots to docs

---------

Co-authored-by: Thomas Roberts <[email protected]>
Co-authored-by: Paulo Arromba <[email protected]>
@opr opr removed this from the 10.0.0 milestone Apr 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
block: checkout Issues related to the checkout block.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants